home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / comm2 / termsorc.lha / Extras / Source / gtlayout-source.lha / LTP_AdjustItemPosition.c < prev    next >
C/C++ Source or Header  |  1995-09-24  |  1KB  |  54 lines

  1. /*  GadTools layout toolkit
  2. **
  3. **  Copyright © 1993-1995 by Olaf `Olsen' Barthel
  4. **  Freely distributable.
  5. **
  6. **  :ts=4
  7. */
  8.  
  9. #include "gtlayout_global.h"
  10.  
  11. #ifdef DO_MENUS
  12.  
  13.     /* LTP_AdjustItemPosition(struct MenuItem *Item,WORD Left,WORD Top):
  14.      *
  15.      *    Calculate the effective positions of the menu items.
  16.      */
  17.  
  18. WORD __regargs
  19. LTP_AdjustItemPosition(struct MenuItem *Item,WORD Left,WORD Top)
  20. {
  21.     ItemNode    *Node;
  22.     WORD         Width = 0;
  23.  
  24.         // Hit the road, Jack...
  25.  
  26.     while(Item)
  27.     {
  28.             // Get back
  29.  
  30.         Node = (ItemNode *)((ULONG)Item - sizeof(struct MinNode));
  31.  
  32.             // Add up the left edge
  33.  
  34.         Node -> Left    = Left    + Node -> Item . LeftEdge;
  35.         Node -> Top        = Top    + Node -> Item . TopEdge;
  36.  
  37.             // Fix up the sub menu
  38.  
  39.         if(Node -> Item . SubItem)
  40.             Node -> Width = LTP_AdjustItemPosition(Node -> Item . SubItem,Node -> Left,Node -> Top);
  41.  
  42.             // Update the local width
  43.  
  44.         if(Node -> Item . LeftEdge + Node -> Item . Width > Width)
  45.             Width = Node -> Item . LeftEdge + Node -> Item . Width;
  46.  
  47.         Item = Item -> NextItem;
  48.     }
  49.  
  50.     return(Width);
  51. }
  52.  
  53. #endif    /* DO_MENUS */
  54.